<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="google" content="notranslate">
    <meta http-equiv="Content-Language" content="en">
    <title>userScripts sandbox</title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
            box-sizing: border-box;
        }

        .error {
            text-align: center;
            margin: 2rem auto;
            color: rgb(255, 37, 37);
            font-size: 20px;
        }
    </style>
    <script>
        const handler = ({ data }) => {
            if (data.type === 'reload-script') {
                try {
                    document.body.innerHTML = ''
                    script = document.createElement('script')
                    script.innerHTML = data.data
                    document.body.appendChild(script)
                } catch (error) {
                    console.log(error)
                    document.body.innerHTML = `<p class="error">运行失败，请检查参数是否为空，或在使用前先检查变量是否为空</p>`
                }
            }
        }
        window.addEventListener('message', handler)
    </script>
</head>

<body>

</body>

</html>